<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <title>商品上架页面</title>

    <link rel="stylesheet" href="../extra.css">
    <!-- Font Awesome Icons -->
    <link rel="stylesheet" href="../../../plugins/font-awesome/css/font-awesome.min.css">
    <!-- IonIcons -->
    <link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="../../../plugins/datatables/dataTables.bootstrap4.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../../../dist/css/adminlte.min.css">
    <!-- Google Font: Source Sans Pro -->
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
    <style>
        .table  td, .table  th {
            border: 1px solid #dee2e6;
        }
    </style>
</head>
<!--
BODY TAG OPTIONS:
=================
Apply one or more of the following classes to to the body tag
to get the desired effect
|---------------------------------------------------------|
|LAYOUT OPTIONS | sidebar-collapse                        |
|               | sidebar-mini                            |
|---------------------------------------------------------|
-->
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <!-- Navbar -->
    <nav class="main-header navbar navbar-expand bg-white navbar-light border-bottom">
        <!-- Left navbar links -->
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" data-widget="pushmenu" href="#"><i class="fa fa-bars"></i></a>
            </li>
            <li class="nav-item d-none d-sm-inline-block">
                <a href="index.html" class="nav-link">主页</a>
            </li>
            <li class="nav-item d-none d-sm-inline-block">
                <a href="#" class="nav-link">联系</a>
            </li>
        </ul>

        <!-- SEARCH FORM -->
        <form class="form-inline ml-3">
            <div class="input-group input-group-sm">
                <input class="form-control form-control-navbar" type="search" placeholder="搜索" aria-label="Search">
                <div class="input-group-append">
                    <button class="btn btn-navbar" type="submit">
                        <i class="fa fa-search"></i>
                    </button>
                </div>
            </div>
        </form>


        <!-- Right navbar links -->
        <ul class="navbar-nav ml-auto">
            <!-- Messages Dropdown Menu -->
            <!--<li class="nav-item dropdown">-->

            <li class="nav-item">
                <button style="font-weight: bold" type="button" class="button-pill button button-caution"
                        onclick="logout()">
                    退出
                </button>
            </li>

            <li class="nav-item">
                <a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#"><i
                        class="fa fa-th-large"></i></a>
            </li>
        </ul>
    </nav>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <aside class="main-sidebar sidebar-dark-primary elevation-4">
        <!-- Brand Logo -->
        <!--<a href="index3.html" class="brand-link">-->
        <!--<img src="dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"-->
        <!--style="opacity: .8">-->
        <!--<span class="brand-text font-weight-light">AdminLTE 3</span>-->
        <!--</a>-->

        <!-- Sidebar -->
        <div class="sidebar">
            <!-- Sidebar user panel (optional) -->
            <div class="user-panel mt-3 pb-3 mb-3 d-flex">
                <div class="image">
                    <img src="../../../dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
                </div>
                <div class="info">
                    <a href="#" class="d-block">商户</a>
                </div>
            </div>

            <!-- Sidebar Menu -->
            <nav class="mt-2">
                <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
                    data-accordion="false">
                    <!-- Add icons to the links using the .nav-icon class
                         with font-awesome or any other icon font library -->
                    <li class="nav-item ">
                        <a href="index.html" class="nav-link">
                            <i class="nav-icon fa fa-dashboard"></i>
                            <p>
                                案件概况
                                <!--<i class="right fa fa-angle-left"></i>-->
                            </p>
                        </a>
                    </li>



                    <li class="nav-item has-treeview">
                        <a href="case.html" class="nav-link ">
                            <i class="nav-icon fa fa-table"></i>
                            <p>
                                案件管理
                                <!--<i class="fa fa-angle-left right"></i>-->
                            </p>
                        </a>
                    </li>

                    <li class="nav-item has-treeview">
                        <a href="#" class="nav-link active">
                            <i class="nav-icon fa fa-table"></i>
                            <p>
                                协查表管理
                                <i class="fa fa-angle-left right"></i>
                            </p>
                        </a>
                        <ul class="nav nav-treeview">
                            <li class="nav-item">
                                <a href="assistant.html" class="nav-link">
                                    <i class="fa fa-circle-o nav-icon"></i>
                                    <p>协查表信息</p>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="feedback.html" class="nav-link">
                                    <i class="fa fa-circle-o nav-icon"></i>
                                    <p>反馈信息</p>
                                </a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </nav>
            <!-- /.sidebar-menu -->
        </div>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">协查信息添加</h1>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item">主页</a></li>
                            <li class="breadcrumb-item active">协查管理</li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->

        </div>
        <!-- /.content-header -->

        <section class="content">
            <div class="row">

                <div class="col-2">

                </div>
                <div class="col-8">





                    <div class="card card-primary">
                        <div class="card-header">
                            <h3 class="card-title">协查信息填写</h3>
                        </div>
                        <!-- /.card-header -->
                        <!-- form start -->
                        <!--data-inputmask="'alias': 'dd/mm/yyyy'" data-mask-->
                        <form role="form">
                            <div class="card-body">
                                <div class="form-group">
                                    <label for="g_name">办案民警 *</label>
                                    <input type="text" class="form-control" id="agent2"
                                           placeholder="输入办案民警">
                                </div>
<!--                                <div class="form-group">-->
<!--                                    <label for="g_name">案件 *</label>-->
<!--                                    <select class="form-control" id="s_i_uuid">-->
<!--                                    </select>-->
<!--                                </div>-->
                                <div class="form-group">
                                    <label for="g_name">使用目的 *</label>
                                    <input type="text" class="form-control" id="md"
                                           placeholder="使用目的">
                                </div>

<!--                                <div class="form-group">-->
<!--                                    <label for="g_ly">备注</label>-->
<!--                                    <input type="text" class="form-control" id="g_ly"-->
<!--                                           placeholder="输入联系方式">-->
<!--                                </div>-->

                                <div class="form-group" id="template">
                                    <label>拟采取网络信息查询监控措施的对象、目标或特定信息 *</label>
                                   <div id='result'>
                                       <div class="card-body table-responsive p-0" style="border: 1px solid #ced4da;margin-bottom: 1rem;">
                                           <table  class="table table-head-fixed text-nowrap" id="obj">
                                               <thead>
                                               <tr>
                                                   <th><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">姓名</font></font></th>
                                                   <th><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">证件种类与号码</font></font></th>
                                                   <th><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">目标或特定信息</font></font></th>
                                                   <th><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">备注</font></font></th>
                                                   <th><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">操作</font></font></th>
                                               </tr>
                                               </thead>

                                           </table>

                                       </div>
                                   </div>
                                    <center>
                                        <button type="button"   class="button button-pill button-lg button-primary" data-toggle="modal" data-target="#exampleModalCenter" >
                                            添加
                                        </button>
                                    </center>
                                </div>
                                <div class="callout callout-info">
                                    <h5>案件信息填写提示</h5>

                                    <p>带*为必填字段，其余可选填.</p>
                                </div>
                            </div>
                        </form>

                    </div>

                    <center>
                        <div class="button-group" style="margin:10px auto">
                            <button type="button" class="button button-pill button-lg button-action"
                                    onclick="addxc()">提交
                            </button>
<!--                            <button type="button" class="button button-pill button-lg button-primary" onclick="reset()">-->
<!--                                重置-->
<!--                            </button>-->
                            <button type="button" class="button button-pill button-lg button-caution"
                                    onclick="location='case.html'">取消
                            </button>
                        </div>
                    </center>

                </div>
                <div class="col-2">
                </div>

            </div>
            <!--&lt;!&ndash; /.row &ndash;&gt;-->
        </section>

    </div>
    <!-- /.content -->
    <!-- /.content-wrapper -->

    <!-- Control Sidebar -->
<!--    <aside class="control-sidebar control-sidebar-dark">-->
<!--        &lt;!&ndash; Control sidebar content goes here &ndash;&gt;-->
<!--    </aside>-->
    <!-- /.control-sidebar -->

    <!-- Main Footer -->
<!--    <footer class="main-footer">-->
<!--        &lt;!&ndash; To the right &ndash;&gt;-->
<!--        <div class="float-right d-none d-sm-block-down">-->
<!--            Anything you want-->
<!--        </div>-->
<!--        &lt;!&ndash; Default to the left &ndash;&gt;-->
<!--        <strong>Copyright &copy; 2018 Solitary.</strong> All rights reserved.-->
<!--    </footer>-->
</div>

<!-- 模板模块-->
<!--<script id="templte" type="text/html">-->
<!--    <div>-->
<!--        <div  >-->
<!--            <label>title:<%=title%></a>号对象、目标或特定信息：</label>-->
<!--            <div class="form-group">-->
<!--                <label for="g_name">姓名 *</label>-->
<!--                <input type="text" class="form-control" id="g_name"-->
<!--                       placeholder="输入文书号">-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label for="g_name">证件种类</label>-->
<!--                <select class="form-control" id="s_i_uuid">-->
<!--                </select>-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label for="g_name">证件号</label>-->
<!--                <input type="text" class="form-control" id="g_name"-->
<!--                       placeholder="输入证件号">-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label for="g_name">目标种类</label>-->
<!--                <select class="form-control" id="s_i_uuid">-->
<!--                </select>-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label for="g_name">目标或特定信息</label>-->
<!--                <input type="text" class="form-control" id="g_name"-->
<!--                       placeholder="输入目标或特定信息">-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label for="g_name">备注</label>-->
<!--                <input type="text" class="form-control" id="g_name"-->
<!--                       placeholder="输入备注">-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered " role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalCenterTitle">拟采取网络信息查询监控措施的对象、目标或特定信息</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" style="text-align:center;" >
                <div >
                            <div class="form-group">
                                <label for="name">姓名 *</label>
                                <input type="text" class="form-control" id="name"
                                       placeholder="姓名，没有身份证写不祥">
                            </div>
                            <div class="form-group">
                                <label for="objecttype_id">证件种类</label>
                                <select class="form-control" id="objecttype_id">
                                    <option value="1">身份证</option>
                                    <option value="2">护照</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="number">证件号</label>
                                <input type="text" class="form-control" id="number"
                                       placeholder="输入证件号，没有写不详">
                            </div>
                            <div class="form-group">
                                <label for="target_id">目标种类</label>
                                <select class="form-control" id="target_id">
                                    <option value="0">微信</option>
                                    <option value="0">支付宝</option>
                                    <option value="0">QQ</option>
                                    <option value="0">QQ群聊</option>
                                    <option value="0">网站</option>
                                    <option value="0">淘宝</option>

                                </select>
                            </div>
                            <div class="form-group">
                                <label for="taget">目标或特定信息</label>
                                <input type="text" class="form-control" id="taget"
                                       placeholder="输入目标或特定信息">
                            </div>
                            <div class="form-group">
                                <label for="remark">备注</label>
                                <input type="text" class="form-control" id="remark"
                                       placeholder="输入备注">
                            </div>
                            <button type="button" class="button button-pill button-lg button-action"
                                    onclick="addobj()">提交
                            </button>
                     </div>
            </div>
                                <!--                <div class="modal-footer">-->
            <!--                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>-->
            <!--                    <button type="button" class="btn btn-primary">Save changes</button>-->
            <!--                </div>-->
        </div>
    </div>
</div>
</div>

<!-- ./wrapper -->

<!-- REQUIRED SCRIPTS -->

<!-- jQuery -->
<script src="../../../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="../../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE -->

<script src="../../../dist/js/adminlte.js"></script>
<!-- DataTables -->
<script src="../../../plugins/datatables/jquery.dataTables.js"></script>
<script src="../../../plugins/datatables/dataTables.bootstrap4.js"></script>

<!-- OPTIONAL SCRIPTS -->
<script src="../../../plugins/chart.js/Chart.min.js"></script>
<script src="../../../dist/js/demo.js"></script>
<script src="../../../dist/js/pages/dashboard3.js"></script>
<script>
  var table
  var user_token = sessionStorage.getItem('user_token');
  var case_id= sessionStorage.getItem('case_id');
  var assistant_id=sessionStorage.getItem('assistant_id');
  var xuhao=0;


   $(function () {
      // renderShopSelect()
       refreshData()
   })



  function checknum(obj) {
    if (/^\d+\.?\d{0,2}$/.test(obj.value)) {
      obj.value = obj.value
    } else {
      obj.value = obj.value.substring(0, obj.value.length - 1)
    }
  }






  function addxc() {
      let form = new FormData();
      let  agent2 = $('#agent2')
          .val()
      let  md = $('#md')
          .val()



      form.append('agent2', agent2)
      form.append('md', md)
      // form.append('objecttype_id', objecttype_id)
      // form.append('taget',taget)
      // form.append('target_id', target_id)
      // form.append('number', number)
      // form.append('case_id', assistant_id)

      var settings = {
          'async': true,
          'crossDomain': true,
          'url': 'http://127.0.0.1:5744/api/assistant/addxc/'+assistant_id,
          'method': 'POST',
          'headers': {
              'Authorization': user_token
          },
          'processData': false,
          'contentType': false,
          'mimeType': 'multipart/form-data',
          'data': form
      }


      $.ajax(settings)
          .done(function (response) {
              response = JSON.parse(response)
              if (response.code == '0') {
                  // alert(response.message)
                  window.location.href = 'assinsert.html'

              } else {
                  alert(response.message)
              }
          })


  }


  function isnull(val) {
    var str = val.replace(/(^\s*)|(\s*$)/g, '')//去除空格;

    if (str == '' || str == undefined || str == null) {
      //return true;
      console.log('空')
    } else {
      //return false;
      console.log('非空')
    }
  }

  function logout() {
    sessionStorage.removeItem('user_token')
    window.location.href = '../common/login.html'

  }
  //对象表
  function addobj() {
      let form = new FormData();
      let  name = $('#name')
          .val()
      let  remark = $('#remark')
          .val()
      let  objecttype_id = $('#objecttype_id')
          .val()
      let  taget = $('#taget')
          .val()
      let  target_id = $('#target_id')
          .val()
      let  number = $('#number')
          .val()
      if(name=="不详"){
          number="不详"
      }
      if(name==""){
          name=="不详"
          number="不详"
      }

      form.append('name', name)
      form.append('remark', remark)
      form.append('objecttype_id', objecttype_id)
      form.append('taget',taget)
      form.append('target_id', target_id)
      form.append('number', number)
      form.append('case_id', assistant_id)

      var settings = {
          'async': true,
          'crossDomain': true,
          'url': 'http://127.0.0.1:5744/api/caseobj/add',
          'method': 'POST',
          'headers': {
              'Authorization': user_token
          },
          'processData': false,
          'contentType': false,
          'mimeType': 'multipart/form-data',
          'data': form
      }


      $.ajax(settings)
          .done(function (response) {
              response = JSON.parse(response)
              if (response.code == '0') {
                  // alert(response.message)
                  $('#name')
                      .val("")
                  $('#remark')
                      .val("")
                  $('#taget')
                      .val("")
                  $('#number')
                      .val("")

                  $('#exampleModalCenter').modal('hide')

                  refreshData()

              } else {
                  alert(response.message)
              }
          })


  }

  // function del(id) {
  //     var user_token = sessionStorage.getItem('user_token')
  //
  //     var settings = {
  //         'async': true,
  //         'crossDomain': true,
  //         'url': 'http://127.0.0.1:5744/api/caseobj/' + id,
  //         'method': 'DELETE',
  //         'headers': {
  //             'Authorization': user_token
  //         }
  //     }
  //
  //
  //     $.ajax(settings)
  //         .done(function (response) {
  //             if (response.code == '0') {
  //                 // alert(response.message)
  //                 table.destroy()
  //                 refreshData()
  //
  //             } else {
  //                 alert(response.message)
  //             }
  //         })
  //
  //
  // }

  function refreshData() {
      var user_token = sessionStorage.getItem('user_token')


      console.log(user_token)
      var settings = {
          'async': true,
          'crossDomain': true,
          'url': 'http://127.0.0.1:5744/api/caseobj/list/'+assistant_id,
          'method': 'GET',
          contentType: "application/json",
          'headers': {
              'Authorization': user_token
          }
      }

      var data = []

      $.ajax(settings)
          .done(function (response) {
              if (response.code == '0') {
                  data = resolveData(response)
                  table = $('#obj')
                      .DataTable({
                          destroy: true,
                          data: data,
                          pagingType: "full_numbers",
                          language: {
                              //"info": "当前第_PAGE_页，共 _PAGES_页",
                              sInfo: "当前显示第 _START_ 到第 _END_ 条，共 _TOTAL_ 条",
                              sInfoFiltered: "(从_MAX_条筛选 )",
                              sInfoEmpty: "共筛选到0条",
                              sSearch: "搜索:",
                              sLengthMenu: "每页显示 _MENU_ 条",
                              sZeroRecords: "未筛选到相关内容",
                              paginate: {
                                  sFirst: "首页",  //首页和尾页必须在pagingType设为full_numbers时才可以
                                  sLast: "尾页",
                                  sPrevious: "上一页",
                                  sNext: "下一页",
                                  first: "First page",
                                  last: "Last page",
                                  next: "Next page",
                                  previous: "Previous page"
                              }

                          },
                          columns: [
                              { data: 'name' },
                              { data: 'number' },
                              { data: 'taget' },
                              { data: 'remark' },
                          ],
                          columnDefs: [
                              // // 将Salary列变为红色
                              // {
                              //   "targets": [5], // 目标列位置，下标从0开始
                              //   "data": "salary", // 数据列名
                              //   "render": function(data, type, full) { // 返回自定义内容
                              //     return "<span style='color:red;'>" + data + "</span>";
                              //   }
                              // },
                              // 增加一列，包括删除和修改，同时将我们需要传递的数据传递到链接中
                              {
                                  'targets': [4], // 目标列位置，下标从0开始
                                  'render': function (data, type, row, meta) { // 返回自定义内容
                                      // return "<a href='/delete?name=" + data + "'>Delete</a>&nbsp;<a href='/update?name=" + data + "'>Update</a>";
                                      return ' <td> ' +
                                          '                                              <button class="btn-danger"\n' +
                                          '                                                    data-toggle="modal"\n' +
                                          '                                                    data-target="#deleteOpponent"\n' +
                                          '                                                    onclick="del(' + row.id + ')">\n' +
                                          '                                                删除\n' +
                                          '                                            </button>\n' +
                                          '\n' +
                                          '                                        </td>'
                                  }
                              }
                          ]
                      })
              } else {

                  alert(response.message)
              }
          })
  }

  function resolveData(response) {
      return response.data
  }

  function del(id) {
      var user_token = sessionStorage.getItem('user_token')

      var settings = {
          'async': true,
          'crossDomain': true,
          'url': 'http://127.0.0.1:5744/api/caseobj/del/' + id,
          'method': 'DELETE',
          'headers': {
              'Authorization': user_token
          }
      }


      $.ajax(settings)
          .done(function (response) {
              if (response.code == '0') {
                  alert(response.message)
                  refreshData()

              } else {
                  alert(response.message)
              }
          })


  }

</script>
</body>
</html>
